package com.longteng.java.web.thread;

/**
 * Created by tianqing.wang
 * DATE : 2018/4/22
 * TIME : 上午10:43
 * PROJECT : web-lesson
 * PACKAGE : com.longteng.java.web.thread
 *
 * @author <a href="mailto:celeskyking@163.com">tianqing.wang</a>
 */
public class ThreadDemo {

    public static class MyRunnable implements Runnable {

        @Override
        public void run() {
            System.out.println(Thread.currentThread().getName());
        }
    }


    public static class MyThread extends Thread {

        @Override
        public void run(){
            while(true){
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName());
            }

        }
    }


    public static void main(String[] args) throws InterruptedException {
//       MyRunnable runnable = new MyRunnable();
//       new Thread(runnable).start();//       new Thread(()-> System.out.println(Thread.currentThread().getName())).start();
       MyThread myThread =  new MyThread();
       myThread.setDaemon(false);
       myThread.start();
    }




}
